Skip to content

chore(dependency): 新增 bcprov-jdk15on 1.70 发行线 - #49

Open
zhouweiye wants to merge 5 commits into
wop-platform:mainfrom
zhouweiye:release/jdk15on-1.70
Open

zhouweiye wants to merge 5 commits into
wop-platform:mainfrom
zhouweiye:release/jdk15on-1.70

Conversation

@zhouweiye

@zhouweiye zhouweiye commented Nov 18, 2026 •

Copy link
Copy Markdown

背景

本仓库当前依赖 bcprov-jdk18on。jdk15on 与 jdk18on 是两个不同的 artifact,但包含同名 org.bouncycastle.* 包;消费者项目只要已经引入 bcprov-jdk15on(存量项目常见于 PDF/证书/老支付 SDK 的传递依赖),classpath 上就会同时出现两个 BC jar,表现为随机 NoSuchMethodError / NoClassDefFoundError。

已确认单纯降低 bcprov-jdk18on 的版本号无效——Maven 只按 groupId:artifactId 仲裁,不同 artifact 必然共存。

方案

新增一条 jdk15on 发行线,与现有 18on 线并行发布,消费者按依赖树选择,无需修改或排除现有依赖:

发行线 坐标 适用项目
jdk15on(本 PR) 0.3.0-jdk15on.1 已有 bcprov-jdk15on(≥1.65)
jdk18on(main) 0.3.0 无 BC 依赖,或已使用 bcprov-jdk18on

选择方法:mvn dependency:tree -Dincludes=org.bouncycastle。

改动

  • 根 pom 与 core 的 BC 坐标切换为 bcprov-jdk15on:1.70(该 artifact 最后一版),japicmp 老 classpath 同步更新
  • 模块版本设为 0.3.0-jdk15on.1,避免覆盖 Central 上已发布的 0.3.0
  • 新增 BouncyCastleVersionGuard:BC < 1.65 时抛 WopError(category=configuration)。校验放在 provider() 取用时而非静态初始化块——静态初始化抛出的运行时异常会被 JVM 包装为 ExceptionInInitializerError,调用方无法按契约捕获(已用 1.64 实测确认)
  • BouncyCastleHolder 公共成员保持不变,japicmp 无 API 变更
  • 新增 docs/release-lines.md:双线选择、Renovate/Dependabot 跨线升级限制、维护者发布约定
  • 新增 SECURITY.md:支持范围、漏洞上报流程、BC 15on EOL 边界
  • CI push 触发增加 release/** 分支

验证

  • mvn -B -ntp verify:5 模块全部 SUCCESS
  • core 451 tests,JaCoCo 行/分支覆盖率 100%
  • 黄金向量与互操作套件全部通过(SM2 固定 k、RSA 2048/3072/4096 确定性签名、SM4-GCM 固定 IV、OAEP、SM2 C1C3C2 等字节级断言),证明 1.70 与 1.85 的线上字节完全一致
  • 运行时守卫实测:1.64 拒绝并直抛 WopError;1.65 / 1.70 通过
  • 依赖树仅剩 org.bouncycastle:bcprov-jdk15on:jar:1.70:compile

需要确认的点

  1. EOL:bcprov-jdk15on 1.70 是最后一版(2021-12),此后安全修复只进入 18on 分支。该线定位为存量项目的过渡发行线,需要明确生命周期与迁移计划。
  2. 版本排序:0.3.0-jdk15on.1 < 0.3.0,依赖更新工具会提示跨线升级。文档已给出 Renovate allowedVersions / Dependabot ignore 配置;若要结构性消除,需要为 15on 线使用独立 artifactId。
  3. 分支维护:15on 线只接收安全与兼容性修复,不合回 main。

相关提交:d53af2f、5162d7b、b8f8a5d

Sourcery 摘要

为已使用 bcprov-jdk15on 的项目提供一个兼容性发布线,同时避免在类路径中引入两种 BouncyCastle 工件。

新功能:

  • 添加基于 BouncyCastle 1.70 的 jdk15on 发布线,供已依赖旧版工件的使用者使用。
  • 添加运行时验证:对于低于 1.65 的不受支持的 BouncyCastle 版本,返回配置错误。

错误修复:

  • 防止通过 SDK 的依赖选择机制同时引入相互冲突的 bcprov-jdk15on 和 bcprov-jdk18on 工件。

增强:

  • 在保留现有公共 API 的同时,将所有模块发布为 0.3.0-jdk15on.1 版本。
  • 说明发布线选择、依赖更新限制、维护范围和安全问题报告方式。

CI:

  • 在 main 和发布分支上运行 CI。

文档:

  • 更新英文和中文使用文档,说明 jdk15on 发布线及其迁移和安全限制。

测试:

  • 添加对 BouncyCastle 版本兼容性和提供程序验证的测试覆盖。

杂项:

  • 将 japicmp 和项目依赖元数据与 jdk15on BouncyCastle 工件保持一致。
Original summary in English

Sourcery 摘要

为使用 bcprov-jdk15on 的用户提供兼容的发布线,同时避免 Bouncy Castle 依赖项在类路径上发生冲突。

新功能:

  • 添加基于 bcprov-jdk15on 1.70 的并行 Bouncy Castle jdk15on 发布线,供已依赖该构件的项目使用。
  • 添加运行时兼容性验证:若 Bouncy Castle 版本低于 1.65,则以配置错误拒绝运行。

错误修复:

  • 防止通过 SDK 依赖项选择同时引入互相冲突的 bcprov-jdk15on 和 bcprov-jdk18on 构件。

增强:

  • 将所有模块发布为 0.3.0-jdk15on.1,同时保留现有公共 API。
  • 将 Bouncy Castle 提供程序验证保留为显式运行时检查,不进行全局注册。

构建:

  • 将项目和 japicmp 的依赖元数据切换为 bcprov-jdk15on 1.70。

CI:

  • 为 main 和 release 分支运行 CI。

文档:

  • 在英文和中文文档中说明发布线选择、依赖项更新限制、维护范围和漏洞报告方式。

测试:

  • 添加对受支持和不受支持的 Bouncy Castle 版本以及提供程序验证的覆盖。

杂项:

  • 统一 Maven 模块中 jdk15on 发布线的元数据。
Original summary in English

Summary by Sourcery

Provide a compatibility release line for consumers using bcprov-jdk15on while preventing Bouncy Castle artifact conflicts on the classpath.

New Features:

  • Add a parallel Bouncy Castle jdk15on release line based on bcprov-jdk15on 1.70 for projects that already depend on that artifact.
  • Add runtime compatibility validation that rejects Bouncy Castle versions below 1.65 with a configuration error.

Bug Fixes:

  • Prevent conflicting bcprov-jdk15on and bcprov-jdk18on artifacts from being introduced together through SDK dependency selection.

Enhancements:

  • Publish all modules as version 0.3.0-jdk15on.1 while preserving the existing public API.
  • Keep Bouncy Castle provider validation as an explicit runtime check without registering the provider globally.

Build:

  • Switch project and japicmp dependency metadata to bcprov-jdk15on 1.70.

CI:

  • Run CI for both main and release branches.

Documentation:

  • Document release-line selection, dependency update restrictions, maintenance boundaries, and vulnerability reporting in English and Chinese documentation.

Tests:

  • Add coverage for supported and rejected Bouncy Castle versions and provider validation.

Chores:

  • Align the jdk15on release-line metadata across the Maven modules.

weiye.zhou added 3 commits November 18, 2026 17:01
- 新增 jdk15on 发行线,版本 0.3.0-jdk15on.1,供已有 bcprov-jdk15on 的项目直接使用
- bcprov-jdk18on 1.85 → bcprov-jdk15on 1.70(15on 最后一版)
- 增加 BC 版本下限守卫(>=1.65),低于下限抛明确配置错误而非 NoSuchMethodError
- README 增加双发行线选择说明
- 全量 verify:448 tests 全绿,行/分支覆盖率 100%,japicmp 无公共 API 变更
- 静态初始化抛出的运行时异常会被 JVM 包装为 ExceptionInInitializerError,
  调用方按 WopError catch 不到;改为 provider() 取用时校验,1.64 实测直抛 WopError
- BouncyCastleHolder 公共成员保持与基线一致,避免 japicmp 误判 API 变更
- 补 requireSupported(Provider) 拒绝路径与单例访问测试
- 新增 docs/release-lines.md:双线选择、Renovate/Dependabot 跨线升级限制、维护者发布约定
- 新增 SECURITY.md:支持范围、漏洞上报流程、BC 15on EOL 边界
- README 增加锁版本与文档入口
- CI 增加 release/** 分支触发;.zcode-review 审查产物不入库
@zhouweiye
zhouweiye requested a review from im47cn as a code owner November 18, 2026 09:39
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a4e6694-8047-4559-811a-b96067c5c4d2
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

审阅者指南

实现

添加运行时 BC 版本检查,并确保 SM2、SM3 和 SM4 路径在执行加密操作前先进行检查,同时将配置错误置于异常包装代码块之外。

  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java L6(已删除的行)、L8-18、L28-39
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleVersionGuard.java L1-39
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm2KeyEncryptStrategy.java L3、L38-41、L52-55
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm2SignatureStrategy.java L3、L43-46、L64
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm2Support.java L3-4、L31-33、L46-48
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm3DigestStrategy.java L7、L22-27
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm4GcmStrategy.java L6、L52-54、L67-69

配置

将父项目和各模块切换到 jdk15on 发布版本及对应的 BC 构件(包括 japicmp 基准版本),确保已发布的模块始终解析到 bcprov-jdk15on 1.70。

  • pom.xml L9-12、L30-32、L50
  • wop-sdk-core/pom.xml L10、L31、L102
  • wop-sdk-jdkhttp/pom.xml L10
  • wop-sdk-okhttp/pom.xml L10
  • wop-sdk-unirest/pom.xml L10

在发布分支上运行 CI,并将审查产物从仓库中忽略。

  • .github/workflows/ci.yml L5
  • .gitignore L12-14

文档

向用户和维护者说明 jdk15on 发布系列、其选择依据及更新工具带来的风险、维护边界和安全问题报告流程。

  • README.en.md L26-36(另有 5 处小修改)
  • README.md L26-36(另有 6 处小修改)
  • SECURITY.md L1-31
  • docs/release-lines.md L1-123

测试

为新增的运行时检查器测试受支持的版本下限、拒绝路径、提供程序标识和单例访问。

  • wop-sdk-core/src/test/java/com/wanlianyida/wop/crypto/BouncyCastleVersionGuardTest.java L1-68

提示和命令

与 Sourcery 交互

  • 触发新一轮审查: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 根据审查评论创建 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以在审查评论下回复 @sourcery-ai issue,以此创建 issue。
  • 生成拉取请求标题: 在拉取请求标题中的任意位置输入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,以随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中你希望放置摘要的位置输入 @sourcery-ai summary,即可随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,以随时(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论,不想再看到它们,这会很有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从头开始进行新一轮审查,这尤其有用——别忘了评论 @sourcery-ai review 来触发新一轮审查!

自定义使用体验

访问你的控制面板,以便:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Implementation

Add a runtime BC version guard and ensure SM2, SM3, and SM4 paths check it before cryptographic work, while keeping configuration errors outside exception-wrapping blocks.

  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java L6 (removed lines), L8-18, L28-39
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleVersionGuard.java L1-39
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm2KeyEncryptStrategy.java L3, L38-41, L52-55
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm2SignatureStrategy.java L3, L43-46, L64
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm2Support.java L3-4, L31-33, L46-48
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm3DigestStrategy.java L7, L22-27
  • wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/strategies/Sm4GcmStrategy.java L6, L52-54, L67-69

Configuration

Switch the parent and modules to the jdk15on release version and BC artifact, including the japicmp baseline, so published modules consistently resolve bcprov-jdk15on 1.70.

  • pom.xml L9-12, L30-32, L50
  • wop-sdk-core/pom.xml L10, L31, L102
  • wop-sdk-jdkhttp/pom.xml L10
  • wop-sdk-okhttp/pom.xml L10
  • wop-sdk-unirest/pom.xml L10

Run CI on release branches and ignore the review artifact in the repository.

  • .github/workflows/ci.yml L5
  • .gitignore L12-14

Documentation

Explain the jdk15on release line, its selection and update-tool risks, maintenance boundary, and security reporting process for users and maintainers.

  • README.en.md L26-36 (+5 small edits)
  • README.md L26-36 (+6 small edits)
  • SECURITY.md L1-31
  • docs/release-lines.md L1-123

Tests

Test the supported-version threshold, rejection path, provider identity, and singleton access for the new runtime guard.

  • wop-sdk-core/src/test/java/com/wanlianyida/wop/crypto/BouncyCastleVersionGuardTest.java L1-68

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@changeset-bot

changeset-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3ccfa71

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您好——我发现了 6 个问题

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/release-lines.md" line_range="60" />
<code_context>
+      interval: "weekly"
+    ignore:
+      # 18on 线的版本,按主干实际发布逐个补充
+      - dependency-name: "com.wanlianyida:wop-sdk-core"
+        versions: ["0.3.0"]
+```
</code_context>
<issue_to_address>
**Adapter updates restore BC conflict**

When a consumer follows the sample and directly depends on an SDK adapter, `ignore` covers only `wop-sdk-core`, so Dependabot can propose an 18on adapter release that brings in the 18on core alongside the consumer's 15on BC jar; accepting it restores both BC jars on the classpath.

Extend the Dependabot ignore rules to cover the 18on adapter artifacts as well as `wop-sdk-core`.
</issue_to_address>

### Comment 2
<location path="pom.xml" line_range="9" />
<code_context>
   <groupId>com.wanlianyida</groupId>
   <artifactId>wop-sdk-core</artifactId>
-  <version>0.3.0</version>
+  <version>0.3.0-jdk15on.1</version>
 </dependency>

</code_context>
<issue_to_address>
**Release line sorts as newer**

When an update tool compares available versions for a consumer currently on the 18on `0.3.0` release, maven treats the unknown `jdk15on` qualifier as newer than the unqualified release, so an updater checking versions for a project on `0.3.0` can select `0.3.0-jdk15on.1`. That moves an 18on consumer onto the 15on line and can reintroduce both BC jars on its classpath.

Use a release-line scheme that sorts in the intended direction, such as separate artifactIds, or constrain update tools for 18on consumers as well.

Also at `README.md:35`, `README.en.md:35`, `docs/release-lines.md:25`.
</issue_to_address>

### Comment 3
<location path="docs/release-lines.md" line_range="25-27" />
<code_context>
+
+## 为什么不能"自动升级"
+
+Maven 版本排序中 `0.3.0-jdk15on.1 < 0.3.0`。Renovate / Dependabot /
+`mvn versions:display-dependency-updates` 会把 18on 线的 `0.3.0` 视为可用升级,
+接受后消费者的 classpath 上会同时出现两个 BC jar,重新触发本仓库要解决的冲突。
+
+**使用 15on 线时,必须锁定精确版本并限制更新工具。**
</code_context>
<issue_to_address>
**Updates can switch release lines**

When an 18on consumer runs Maven-aware dependency updates, maven `ComparableVersion` orders the unrecognized `jdk15on` qualifier after the release version, so Maven-aware update tools can offer `0.3.0-jdk15on.1` as an upgrade from `0.3.0`. Accepting it adds `bcprov-jdk15on` alongside an existing `bcprov-jdk18on`, recreating the classpath conflict.

Correct the Maven ordering guidance and document constraints for both release lines, or publish the lines under distinct artifactIds.

Also at `README.md:35`, `README.en.md:35`.
</issue_to_address>

### Comment 4
<location path="wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleVersionGuard.java" line_range="27" />
<code_context>
+
+    /** 版本守卫:低于 {@link #MIN_VERSION} 明确拒绝。 */
+    static Provider requireSupported(Provider provider) {
+        requireSupportedVersion(provider.getVersion());
+        return provider;
+    }
</code_context>
<issue_to_address>
**SM2 skips version rejection**

When a consumer resolves `bcprov-jdk15on` below 1.65 and invokes an SM2 strategy directly, `Sm2SignatureStrategy` and `Sm2KeyEncryptStrategy` call lightweight BC APIs without reaching `BouncyCastleHolder.provider()` or `BouncyCastleVersionGuard.requireSupported`, so the operation bypasses the fail-fast check and proceeds without the promised configuration error.

Make every exposed SM2 strategy check the BC version before invoking BC APIs.

Also at `wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java:33`, `docs/release-lines.md:20-21`.
</issue_to_address>

### Comment 5
<location path="wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java" line_range="33" />
<code_context>
+     */
     public static Provider provider() {
-        return PROVIDER;
+        return BouncyCastleVersionGuard.requireSupported(PROVIDER);
     }

</code_context>
<issue_to_address>
**Configuration errors become crypto failures**

When BC is below 1.65 and a caller uses an SM3 or SM4 strategy, `Sm3DigestStrategy` and the SM4 paths catch the guard's `WopError` as `Exception` and wrap it in `CryptoException`; `WopClient` can then return a generic inbound failure, so callers see an operation or verification failure instead of a configuration error.

Rethrow the guard's `WopError` before the SM3 and SM4 strategies handle other exceptions.
</issue_to_address>

### Comment 6
<location path="wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java" line_range="33" />
<code_context>
+     */
     public static Provider provider() {
-        return PROVIDER;
+        return BouncyCastleVersionGuard.requireSupported(PROVIDER);
     }

</code_context>
<issue_to_address>
**Rejected provider stays registered**

When the classpath supplies BC below 1.65 and no provider named BC was already registered, `BouncyCastleHolder` initializes `PROVIDER` through `register()`, which calls `Security.addProvider` before `requireSupported` rejects it, leaving the unsupported provider visible to JVM-wide default lookup; later consumers can select it.

Check the provider version before registering it, or remove it from the registry if the check fails.
</issue_to_address>

Sourcery 评估

需要人工审查。 需要先处理 6 项发现;此外,此发布线使 SM2/SM3/SM4 操作使用 BouncyCastle 1.70,这是一个明确已停止维护的版本,因此采用此版本的使用者,其加密操作可能会因该实现中的缺陷而受到影响。回退只能阻止未来继续使用,但无法撤销已经暴露的密钥或数据,也无法撤销已经生成的签名。

阻塞性发现:docs/release-lines.md:60、pom.xml:9、docs/release-lines.md:27、wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleVersionGuard.java:27、wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java:33,以及另外 1 项


Sourcery 对开源项目免费——如果您喜欢我们的审查,请考虑分享 ✨
Original comment in English

Hey - I've found 6 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/release-lines.md" line_range="60" />
<code_context>
+      interval: "weekly"
+    ignore:
+      # 18on 线的版本,按主干实际发布逐个补充
+      - dependency-name: "com.wanlianyida:wop-sdk-core"
+        versions: ["0.3.0"]
+```
</code_context>
<issue_to_address>
**Adapter updates restore BC conflict**

When a consumer follows the sample and directly depends on an SDK adapter, `ignore` covers only `wop-sdk-core`, so Dependabot can propose an 18on adapter release that brings in the 18on core alongside the consumer's 15on BC jar; accepting it restores both BC jars on the classpath.

Extend the Dependabot ignore rules to cover the 18on adapter artifacts as well as `wop-sdk-core`.
</issue_to_address>

### Comment 2
<location path="pom.xml" line_range="9" />
<code_context>
   <groupId>com.wanlianyida</groupId>
   <artifactId>wop-sdk-core</artifactId>
-  <version>0.3.0</version>
+  <version>0.3.0-jdk15on.1</version>
 </dependency>

</code_context>
<issue_to_address>
**Release line sorts as newer**

When an update tool compares available versions for a consumer currently on the 18on `0.3.0` release, maven treats the unknown `jdk15on` qualifier as newer than the unqualified release, so an updater checking versions for a project on `0.3.0` can select `0.3.0-jdk15on.1`. That moves an 18on consumer onto the 15on line and can reintroduce both BC jars on its classpath.

Use a release-line scheme that sorts in the intended direction, such as separate artifactIds, or constrain update tools for 18on consumers as well.

Also at `README.md:35`, `README.en.md:35`, `docs/release-lines.md:25`.
</issue_to_address>

### Comment 3
<location path="docs/release-lines.md" line_range="25-27" />
<code_context>
+
+## 为什么不能"自动升级"
+
+Maven 版本排序中 `0.3.0-jdk15on.1 < 0.3.0`。Renovate / Dependabot /
+`mvn versions:display-dependency-updates` 会把 18on 线的 `0.3.0` 视为可用升级,
+接受后消费者的 classpath 上会同时出现两个 BC jar,重新触发本仓库要解决的冲突。
+
+**使用 15on 线时,必须锁定精确版本并限制更新工具。**
</code_context>
<issue_to_address>
**Updates can switch release lines**

When an 18on consumer runs Maven-aware dependency updates, maven `ComparableVersion` orders the unrecognized `jdk15on` qualifier after the release version, so Maven-aware update tools can offer `0.3.0-jdk15on.1` as an upgrade from `0.3.0`. Accepting it adds `bcprov-jdk15on` alongside an existing `bcprov-jdk18on`, recreating the classpath conflict.

Correct the Maven ordering guidance and document constraints for both release lines, or publish the lines under distinct artifactIds.

Also at `README.md:35`, `README.en.md:35`.
</issue_to_address>

### Comment 4
<location path="wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleVersionGuard.java" line_range="27" />
<code_context>
+
+    /** 版本守卫:低于 {@link #MIN_VERSION} 明确拒绝。 */
+    static Provider requireSupported(Provider provider) {
+        requireSupportedVersion(provider.getVersion());
+        return provider;
+    }
</code_context>
<issue_to_address>
**SM2 skips version rejection**

When a consumer resolves `bcprov-jdk15on` below 1.65 and invokes an SM2 strategy directly, `Sm2SignatureStrategy` and `Sm2KeyEncryptStrategy` call lightweight BC APIs without reaching `BouncyCastleHolder.provider()` or `BouncyCastleVersionGuard.requireSupported`, so the operation bypasses the fail-fast check and proceeds without the promised configuration error.

Make every exposed SM2 strategy check the BC version before invoking BC APIs.

Also at `wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java:33`, `docs/release-lines.md:20-21`.
</issue_to_address>

### Comment 5
<location path="wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java" line_range="33" />
<code_context>
+     */
     public static Provider provider() {
-        return PROVIDER;
+        return BouncyCastleVersionGuard.requireSupported(PROVIDER);
     }

</code_context>
<issue_to_address>
**Configuration errors become crypto failures**

When BC is below 1.65 and a caller uses an SM3 or SM4 strategy, `Sm3DigestStrategy` and the SM4 paths catch the guard's `WopError` as `Exception` and wrap it in `CryptoException`; `WopClient` can then return a generic inbound failure, so callers see an operation or verification failure instead of a configuration error.

Rethrow the guard's `WopError` before the SM3 and SM4 strategies handle other exceptions.
</issue_to_address>

### Comment 6
<location path="wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java" line_range="33" />
<code_context>
+     */
     public static Provider provider() {
-        return PROVIDER;
+        return BouncyCastleVersionGuard.requireSupported(PROVIDER);
     }

</code_context>
<issue_to_address>
**Rejected provider stays registered**

When the classpath supplies BC below 1.65 and no provider named BC was already registered, `BouncyCastleHolder` initializes `PROVIDER` through `register()`, which calls `Security.addProvider` before `requireSupported` rejects it, leaving the unsupported provider visible to JVM-wide default lookup; later consumers can select it.

Check the provider version before registering it, or remove it from the registry if the check fails.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 6 findings to address first, and this release line makes SM2/SM3/SM4 operations use BouncyCastle 1.70, an explicitly unmaintained version, so a flaw in that implementation could compromise cryptographic operations for consumers who adopt it. Reverting would stop future use but could not undo any keys or data already exposed or signatures already produced.

Blocking findings: docs/release-lines.md:60, pom.xml:9, docs/release-lines.md:27, wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleVersionGuard.java:27, wop-sdk-core/src/main/java/com/wanlianyida/wop/crypto/BouncyCastleHolder.java:33, and 1 more


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docs/release-lines.md Resolved
Comment thread pom.xml Resolved
Comment thread docs/release-lines.md Resolved
@zhouweiye

Copy link
Copy Markdown
Author

关于 security/snyk 的 4 项失败

本 PR 相对 main 只有一处依赖变更:bcprov-jdk18on:1.85 → bcprov-jdk15on:1.70(该 artifact 的最后一版)。失败项来自这个版本在漏洞库中的存量记录。

说明:我没有 im47cn Snyk 组织的报告权限,以下是基于 OSV 公开数据 + 代码路径的分析。OSV 对 org.bouncycastle:bcprov-jdk15on@1.70 返回 5 条;Snyk 报 4 条,差异应来自严重度或库版本过滤。

漏洞 影响面 本 SDK 是否使用相关 API
CVE-2024-34447 证书路径 / DNS 名校验 否
CVE-2024-29857 X.509 证书解析 CPU DoS 否
CVE-2023-33201 X500Name / LDAP DN 注入 否
CVE-2024-30171 RSA PKCS#1 v1.5 解密计时侧信道(Marvin) 否
CVE-2023-33202 不可信 ASN.1 解析 DoS 否(仅解析自身生成的 DER)

核对依据(wop-sdk-core/src/main):

  • 无证书解析调用(CertificateFactory / X509Certificate),无 LDAP / DNS 相关代码;
  • RSA 加签使用 SHA256withRSA(RsaPkcs1SignatureStrategy),PKCS#1 v1.5 仅用于签名,不用于解密;
  • DEK 解包使用 RSA/ECB/OAEPPadding + SHA-256 / MGF1-SHA-256(RsaOaepKeyEncryptStrategy);
  • SM2 验签输入为定长 64 字节 r‖s,不解析外部 ASN.1/DER。

因此上述 CVE 的触发路径在当前实现中不可达;但它们确实存在于 1.70 的代码里,Snyk 按版本判定失败。

请求

bcprov-jdk15on 1.70 是该 artifact 的最后一版(2021-12),15on 发行线只能使用它。发行线定位与安全边界见 docs/release-lines.md、SECURITY.md。

恳请维护者在 im47cn 的 Snyk 组织中为本 PR / 15on 发行线配置 ignore 或 waiver,建议带复核期限(例如 6 个月),到期重新评估迁移。

如果贵方安全策略不接受豁免,我们也可以改为在 wop-sdk-core 内 shade + relocate BC 1.85:消费者同样零改动,且不引入 1.70 的 CVE,代价是 jar 增大 ~8MB,并需要把 Sm2Support 等公共 API 中的 BC 类型清理掉。

请告知倾向,我们按结论调整。谢谢!

weiye.zhou added 2 commits November 18, 2026 17:57
- SM2 策略走 BC 轻量 API,不经过 BouncyCastleHolder,此前可绕过版本守卫;
  现在 sign/verify/encrypt/decrypt 与 Sm2Support 入口均先校验
- SM3/SM4/SM2 的 provider 校验移到 try 之外,配置错误不再被包装为 CryptoException
- 移除 Security.addProvider:所有查找显式传 provider,避免被拒绝的实例残留在全局表
- Maven ComparableVersion 把未知限定符排在发布版之后:0.3.0-jdk15on.1 > 0.3.0
- 补充 18on 与 15on 两个方向的跨线升级限制,Dependabot 覆盖全部四个构件
- 注明版本方案为临时折中,结构性隔离需独立 artifactId
@zhouweiye

Copy link
Copy Markdown
Author

已处理 Sourcery 的 6 条意见

推送 2415211、3ccfa71(分支 release/jdk15on-1.70)。逐条对应:

  1. Dependabot 只覆盖 core → docs/release-lines.md 的 ignore 示例扩展到全部四个构件,并补充 18on 项目排除 15on 线的规则。

  2. 发布线排序较新 / 3. 更新可能切换发布线 → 已更正。用 Maven ComparableVersion 实测:

    0.3.0-jdk15on.1 vs 0.3.0 => 2 (jdk15on 更新)
    

    未识别限定符确实排在发布版之后。文档改为说明两个方向的跨线风险(18on 用户被拉向 15on、15on 用户在主干发 0.3.1+ 后被拉回 18on),并分别给出两条线的 Renovate 限制;同时注明单坐标空间无法靠排序隔离,结构性方案是独立 artifactId。

  3. SM2 未执行版本拒绝检查 → Sm2SignatureStrategy / Sm2KeyEncryptStrategy 的 sign / verify / encrypt / decrypt 在调用 BC 轻量 API 前显式校验;Sm2Support.toPublicParams / toPrivateParams 同样覆盖。

  4. 配置错误变成加密失败 → SM3 / SM4 / SM2 的 provider() 调用移到 try 之外。BC 1.64 实测三个策略均直接抛出 WopError,不再被包装为 CryptoException。

  5. 被拒绝的 Provider 仍注册 → 移除 Security.addProvider,所有 JCA 查找显式传入 provider 实例;实测使用后 Security.getProvider("BC") 为 null,不再污染全局 Provider 表。

验证

  • mvn -B -ntp verify:5 模块 SUCCESS
  • core 451 tests,JaCoCo 行/分支 100%
  • japicmp:无公共 API 变更
  • 运行时探针(BC 1.64):SM3 / SM4 / SM2 全部 THREW com.wanlianyida.wop.WopError: BouncyCastle 版本过低...
  • 运行时探针(BC 1.70):SM3 32B、SM4 正常、Security.getProvider("BC") == null

Snyk 的 4 项失败仍来自 bcprov-jdk15on:1.70 的存量 CVE,与本轮修复无关;豁免请求见上一条评论。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants